<!DOCTYPE html>
<html lang="en">
	<include file="Public:header" />
	<include file="Public:page_css" />
	<link rel="stylesheet" href="__PUBLIC__/Admin/css/checkbox.css" />
	<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
	<include file="Public:nav" />
	<div class="row">
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-lg-12">
				<h2>前台角色权限配置</h2>
				<ol class="breadcrumb">
					<li>
						<a href="{:U('Index/index')}"> <i class="fa fa-home"></i>
							主页
						</a>
					</li>
					<li>
						<a>系统管理</a>
					</li>
					<li>
						<a>角色管理</a>
					</li>
					<li> <strong>前台角色权限配置</strong>
					</li>
				</ol>
			</div>
		</div>
		<br />
	</div>
	<div class="row">
		<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<form class="form-horizontal" name="admin_group_access" id="admin_group_access" method="post" action="__URL__/home_group_access">
				<input name="id" id="id" type="hidden" value="{$admin_group.id}" />
				<div class="ibox-title">
						<h5><i class="fa fa-tasks"></i> 前台角色权限配置</h5>
					</div>
				<div class="ibox-content">
				<table width="90%" class="table table-bordered" border="0" align="center" cellpadding="0" cellspacing="0">
				<div class="form-group">
					<label class="col-sm-1 control-label">用户组名：</label>
					<div class="col-sm-2">
						<input name="title" id="title" class="form-control" readonly="" value="{$admin_group.title}" />
					</div>
				</div>
					<tr>
						<td height="30" >
							配置规则:
							<br />
							1、由于页面原因，前台角色权限分配为三级，同时控制左侧导航以及用户前台角色权限
							<br />
							2、部分不需要分配的前台角色权限需要在AUTH的控制器里手动添加
							<br />
							3、如果有选择第三级前台角色权限，那么一级和二级前台角色权限也必须勾选
						</td>
					</tr>
					<tr>
						<td height="30" style="line-height:25px;">
							<label class="pos-rel">
								<input type="checkbox" class="ace ace-checkbox-2"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
								<span class="lbl">前台角色权限全选</span>
							</label>
						</td>
					</tr>
					<foreach name="datas" item="vo">
						<if condition="$vo['pid'] eq 0">
							<tr>
								<td>
									<label>
										<input <if condition="strstr($admin_group['rules'],$vo['id']) eq true">checked</if>
									name="new_rules[]" class="ace ace-checkbox-2" type="checkbox"  value="{$vo.id}" />
									<span class="lbl"> <strong> {$vo.title}</strong>
									</span>
								</label>
							</td>
						</tr>
						<foreach name="datas" item="sub">

							<if condition="$sub['pid'] eq $vo['id']">

								<tr>
									<td style="padding-left:40px;">
										<label>
											<input <if condition="strpos($admin_group['rules'],','.$sub['id'].',') GT -1 ">checked</if>
										name="new_rules[]" id="{$sub.id}" class="ace ace-checkbox-2" type="checkbox"  value="{$sub.id}" />
										<span class="lbl"> {$sub.title}</span>
									</label>
								</td>
							</tr>
							<foreach name="datas" item="subb">
								<if condition="$subb['pid'] eq $sub['id']">

									<tr>
										<td style="padding-left:70px;">
											<label>
												<input <if condition="strpos($admin_group['rules'],','.$subb['id'].',') GT -1 ">checked</if>
											name="new_rules[]" id="{$subb.id}" class="ace ace-checkbox-2" type="checkbox"  value="{$subb.id}" />
											<span class="lbl"> {$subb.title}</span>
										</label>
									</td>
								</tr>
								<volist name='datas' id='subbb'>

									<if condition="$subbb['pid'] eq $subb['id']">
										<tr>
											<td style="padding-left:80px;">
												<label>
													<input <if condition="strpos($admin_group['rules'],','.$subbb['id'].',') GT -1 ">checked</if>
												name="new_rules[]" id="{$subbb.id}" class="ace ace-checkbox-2" type="checkbox"  value="{$subbb.id}" />
												<span class="lbl"> {$subbb.title}</span>
											</label>
										</td>
									</tr>
								</if>
							</volist>
						</if>
					</foreach>
				</if>
			</foreach>
		</if>
	</foreach>
</table>
<div class="clearfix form-actions">
	<div class="col-md-offset-3 col-md-9">
		<button class="btn btn-info" type="submit"> <i class="fa fa-check bigger-110"></i>
			保存
		</button>
		&nbsp; &nbsp; &nbsp;
		<button class="btn" type="reset">
			<i class="ace-icon fa fa-undo bigger-110"></i>
			重置
		</button>
	</div>
</div>
</div>

</form>
</div>
</div>
</div>
<div class="hr hr-24"></div>
<br/><br/>
<include file='Public:footer' />

<script type="text/javascript">

			
	function unselectall(){

		if(document.myform.chkAll.checked){
				document.myform.chkAll.checked = document.myform.chkAll.checked&0;
			}
		}



	function CheckAll(form){

		for (var i=0;i<form.elements.length;i++){
			var e = form.elements[i];
			if (e.Name != 'chkAll'&&e.disabled==false)
			e.checked = form.chkAll.checked;

		}
	}

	
	$(function(){
		
		$('#admin_group_access').ajaxForm({
			
			success: complete, // 这是提交后的方法
			dataType: 'json'
		});
		
	
		function complete(data){
			if(data.status==1){
				layer.alert(data.info, {icon: 6}, function(index){
	 			layer.close(index);
				window.location.href=data.url;
				});
			}else{
				layer.alert(data.info, {icon: 5});
				return false;	
			}
		}
	 
	});
	</script>
	</body>
</html>